package com.tulingxueyuan.mall.modules.oms.controller;


import com.tulingxueyuan.mall.common.api.CommonResult;
import com.tulingxueyuan.mall.modules.oms.model.OmsOrderSetting;
import com.tulingxueyuan.mall.modules.oms.service.OmsOrderSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 订单设置表 前端控制器
 * </p>
 *
 * @author zhaofuhao
 * @since 2022-03-03
 */
@RestController
@Api(tags = "OmsOrderSettingController", description = "订单设置管理")
@RequestMapping("/orderSetting")
public class OmsOrderSettingController {
    @Autowired
    private OmsOrderSettingService orderSettingService;
   /**
   *   return request({
   *     url:'/orderSetting/'+id,
   *     method:'get',
   *   })
   */
   @ApiOperation("获取指定订单设置")
   @GetMapping("/{id}")
   @ResponseBody
   public CommonResult getItem(@PathVariable long id){
       OmsOrderSetting omsOrderSetting = orderSettingService.getById(id);
       return CommonResult.success(omsOrderSetting);

   }
    /**
     *   return request({
     *     url:'/orderSetting/update/'+id,
     *     method:'post',
     *     data:data
     *   })
     */
    @ApiOperation("修改指定订单设置")
    @PostMapping("/update/{id}")
    public CommonResult update(@PathVariable long id,@RequestBody OmsOrderSetting orderSetting){
        boolean count = orderSettingService.updateById(orderSetting);
        if (count){
            return CommonResult.success(count);
        }
        return CommonResult.failed();


    }
}

